import java.io.DataInputStream;
import java.io.FileInputStream;

/**
 * @projectName: com.xiayuanxing.designPattern
 * @className: CoffeeBar
 * @author: xiayuanxing
 * @description: TODO
 * @date: 2021/12/28 11:51
 * @version: 1.0
 */
public class CoffeeBar {

    public static void main(String[] args)throws Exception {


        System.out.println("====================================================================");
        // 说明:
        // 1.InputStream是抽象类,类似我们前面讲的Drink
        // 2.FileInputStream是InputStream子类，类似我们前面的DeCaf,LongBlack
        // 3.FilterInputStream是InputStream子类：类似我们前面的Decorator修饰者
        // 4.DataInputStream是FilterInputStream子类，具体的修饰者，类似前面的Milk,Soy等
        // 5.FilterInputStream类有protected volatile InputStream in;即含被装饰者
        // 6.分析得出在jdk的io体系中，就是使用装饰者模式
        DataInputStream dis = new DataInputStream(new FileInputStream("d:\\abc.txt"));
        System.out.println(dis.read());dis.close();
        System.out.println("====================================================================");




        System.out.println("====================================================================");
        //装饰者模式下的订单：2份巧克力+一份牛奶的LongBlack
        //1.点一份LongBlack
        Drink order = new LongBlack();
        System.out.println("费用1="+order.cost());
        System.out.println("描述="+order.getDes());


        //2.加一份牛奶
        order = new Milk(order);
        System.out.println("order加入一份牛奶，费用="+order.cost());
        System.out.println("order加入一份牛奶，描述="+order.getDes());

        //3.加一份巧克力
        order = new Chocolate(order);
        System.out.println("order加入一份牛奶加入一份巧克力，费用="+order.cost());
        System.out.println("order加入一份牛奶加入一份巧克力，描述="+order.getDes());

        //4.再加一份巧克力
        order = new Chocolate(order);
        System.out.println("order加入一份牛奶加入二份巧克力，费用="+order.cost());
        System.out.println("order加入一份牛奶加入二份巧克力，描述="+order.getDes());
        System.out.println("====================================================================");
    }
}
